//
//  APIQuotaAnalysisManager.m
//  cocoapodText
//
//  Created by apple on 16/10/19.
//  Copyright © 2016年 apple. All rights reserved.
//
#import "NetTool.h"
#import "AFNetworking.h"
#import "APIQuotaAnalysisManager.h"

@interface APIQuotaAnalysisManager()

@end
@implementation APIQuotaAnalysisManager

- (void)fsgy_api_quota_analysis_withFalg:(NSString *)falg{
    AFHTTPSessionManager *session = [AFHTTPSessionManager manager];
    //申明返回的结果是json类型
    session.responseSerializer = [AFJSONResponseSerializer serializer];
    //如果报接受类型不一致请替换一致text/html或别的
    session.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/plain"];
    NSString *neturl=[NetTool fsgy_info_energy_quota_analysis_area];
    NSDictionary *params=@{@"action":@"showTree",@"esCode":@"01",@"orgNo":@"520100000",@"structType":@"4",@"id":@"520100000:4"};
    [session GET:neturl parameters:params success:^(NSURLSessionDataTask *task, id responseObject) {
        if([_delegate respondsToSelector:@selector(onQuotaAnalysisManager:result:Flag:)]){
            [_delegate onQuotaAnalysisManager:self result:responseObject Flag:falg];
        }
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        [CommonTool isSessionExpired:task];
    }];
}

/**
 *@param esCode=01 备注：esCode传送电水冷编码 电：01，水：02 冷 05
 *@param structType=4 备注：区域=4 分项=3 行业=4
 *@param xslx=1 备注：月=2 年=3
 *@param startTime=201508
 *@param endTime=201607
 *@param orgid 区域时格式为：id:name:00 如："520100000:4: 贵阳市 :00"
 */
-(void)fsgy_api_quota_analysis_withFalg:(NSString *)falg esCode:(NSString *)esCode  structType:(NSString *)structType xslx:(NSString *)xslx startTime:(NSString *)startTime endTime:(NSString *)endTime orgid:(NSString *)orgid{
    AFHTTPSessionManager *session = [AFHTTPSessionManager manager];
    //申明返回的结果是json类型
    session.responseSerializer = [AFJSONResponseSerializer serializer];
    //如果报接受类型不一致请替换一致text/html或别的
    session.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/plain"];
    NSString *neturl=[NetTool fsgy_info_energy_quota_analysis_area];
    NSDictionary *params=@{@"action":@"showChart",@"esCode":esCode,@"xslx":xslx,@"structType":structType,@"startTime":startTime,@"endTime":endTime,@"orgid":orgid};
    [session GET:neturl parameters:params success:^(NSURLSessionDataTask *task, id responseObject) {
        if([_delegate respondsToSelector:@selector(onQuotaAnalysisManager:result:Flag:)]){
            [_delegate onQuotaAnalysisManager:self result:responseObject Flag:falg];
        }
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        [CommonTool isSessionExpired:task];
    }];
}

@end
